In [1]:
from path_helpers import path
from droplet_planning import svg_polygons_to_df
from dmf_device_ui.tesselate import tesselate_shapes_frame
from dmf_device_ui.plot import plot_shapes
from dmf_device_ui.point_query import get_shapes_pymunk_space
from dmf_device_ui.device import ShapesCanvas
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
drawing_shape = pd.Series([1920, 1080], index=['width', 'height'])
device_svg = 'static/device.svg'
device_canvas = ShapesCanvas.from_svg(device_svg, padding_factor=0.1, canvas_shape=drawing_shape)
In [3]:
svg_shape = device_canvas.source_shape
svg_axis = device_canvas.df_shapes[['x', 'y']].plot(kind='scatter', x='x', y='y',
xlim=(0, svg_shape.width),
ylim=(0, svg_shape.height))
drawing_axis = (device_canvas.df_canvas_shapes[['x', 'y']]
.plot(kind='scatter', x='x', y='y',
xlim=(0, device_canvas.canvas_shape.width),
ylim=(0, device_canvas.canvas_shape.height)))
svg_axis.set_aspect(True)
drawing_axis.set_aspect(True)
In [4]:
device_canvas.canvas_offset, device_canvas.canvas_scale
Out[4]:
In [5]:
axis = plot_shapes(device_canvas.df_canvas_tesselations, ['path_id', 'triangle_i'],
fc='none')
plot_shapes(device_canvas.df_canvas_shapes, ['path_id'], alpha=.3, axis=axis)
axis.set_aspect(True)
axis.set_xlim(0, device_canvas.canvas_shape.width)
axis.set_ylim(0, device_canvas.canvas_shape.height)
pass
In [6]:
device_canvas.find_shape(1000, 480)
Out[6]: